home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / pm-utils / sleep.d / 94cpufreq < prev    next >
Text File  |  2009-10-06  |  1KB  |  47 lines

  1. #!/bin/sh
  2. # Ensure cpu governor is set to something sane.
  3. # TODO: Which of the cpu governors is still insane?  File bugs against
  4. #       those that are.
  5.  
  6. . "${PM_FUNCTIONS}"
  7.  
  8. [ -d /sys/devices/system/cpu/ ] || exit $NA
  9.  
  10. hibernate_cpufreq()
  11. {
  12.     ( cd /sys/devices/system/cpu/
  13.     for x in cpu[0-9]*; do
  14.         # if cpufreq is a symlink, it is handled by another cpu. Skip.
  15.         [ -L "$x/cpufreq" ] && continue
  16.         gov="$x/cpufreq/scaling_governor"
  17.         # if we do not have a scaling_governor file, skip.
  18.         [ -f "$gov" ] || continue
  19.         # if our temporary governor is not available, skip.
  20.         grep -q "$TEMPORARY_CPUFREQ_GOVERNOR" \
  21.             "$x/cpufreq/scaling_available_governors" || continue
  22.         savestate "${x}_governor" < "$gov"
  23.         echo "$TEMPORARY_CPUFREQ_GOVERNOR" > "$gov"
  24.     done )
  25. }
  26.  
  27. thaw_cpufreq()
  28. {
  29.     ( cd /sys/devices/system/cpu/
  30.     for x in cpu[0-9]*/cpufreq/scaling_governor ; do
  31.         [ -f "$x" ] || continue
  32.         state_exists "${x%%/*}_governor" || continue
  33.         restorestate "${x%%/*}_governor" > "$x"
  34.     done )
  35. }
  36.  
  37. case "$1" in
  38.     suspend|hibernate)
  39.         hibernate_cpufreq
  40.         ;;
  41.     resume|thaw)
  42.         thaw_cpufreq
  43.         ;;
  44.     *) exit $NA
  45.         ;;
  46. esac
  47.